*Multilevel Regime Decoupling: The Territorial Dimension of Autocratization and Contemporary Regime Change*
*REPLICATION CODE 1 of 4
*
*GET V-DEM DATA FROM: https://v-dem.net/data/the-v-dem-dataset/country-year-v-dem-fullothers-v14/
*
*LOAD V-DEM DATA:
use "V-Dem-CY-Full+Others-v13.dta", clear
*
*STANDARDIZE VARIABLES OF INTEREST
*GEN POSITIVE VALUES
gen v2elffelr_pos=v2elffelr+3.459
gen v2elsnlsff_pos=v2elsnlsff+3.219
gen v2elfrfair_pos=v2elfrfair+3.373
*STD BETWEEN 0 & 1
foreach var in v2elffelr_pos v2xel_frefair v2elsnlsff_pos v2elfrfair_pos {
	qui sum `var'
	gen `var'_standard= (`var' - `r(min)') / (`r(max)'-`r(min)')
}
*CHECK
sum v2xel_frefair_standard
sum v2elffelr_pos_standard
sum v2elsnlsff_pos_standard
sum v2elfrfair_pos_standard
*
*IDENTIFY SUBNATIONAL ELECTIONS BY REGIME TYPE
gen polity_demdummy=.
replace polity_demdummy=1 if e_polity2>5
replace polity_demdummy=0 if polity_demdummy==. & e_polity2==-66| e_polity2==-88 
replace polity_demdummy=0 if e_polity2<6
*GENERARTE SHARE
bys year: egen subnat_elect_POLITYnatDEM=mean(v2elffelrbin_ord) if polity_demdummy==1
bys year: egen subnat_elect_POLITYnatAUTH=mean(v2elffelrbin_ord) if polity_demdummy==0
*SHARE 3-YEAR MA
xtset country_id year
gen subnat_elect_POLITYnatDEM_MA=(F1.subnat_elect_POLITYnatDEM+subnat_elect_POLITYnatDEM+L1.subnat_elect_POLITYnatDEM)/3
xtset country_id year
gen subnat_elect_POLITYnatAUTH_MA=(F1.subnat_elect_POLITYnatAUTH+subnat_elect_POLITYnatAUTH+L1.subnat_elect_POLITYnatAUTH)/3
**************************************************************************************************************************************************
**************************************************************************************************************************************************
**************************************************************************************************************************************************
*FIGURE 1: The Puzzling Territorial Dimension of Autocratization & Contemporary Regime Change
*PANEL A
tsline subnat_elect_POLITYnatDEM_MA   if year>1999, yaxis(1) lcol(dkgreen) || ///
tsline subnat_elect_POLITYnatAUTH_MA  if year>1999, yaxis(2) lcol(purple)  || /// 
, xtitle("Year", size(small)) ytitle("Share Dem. (3-year moving avg.)", size(small) axis(1)) ///
 ytitle("Share Auth. (3-year moving avg.)", size(small) axis(2)) /// 
 subtitle("Share of Countries w/Subnat. Elections by Nat. Regime Type ", size(small)) /// 
 graphregion(margin(2 2 2 2)) plotregion(margin(0 0 0 0)) ysize(1) xsize(1) /// 
 ylabel(,labsize(small) axis(1)) ylabel(,labsize(small) axis(2)) xlabel(,labsize(small)) /// 
 leg(pos(5) ring(0) row(2) label(1 "Dem.w/Subnat. Elections") label(2 "Auth.w/Subnat. Elections") size(small)) /// 
 scheme(lean1) yscale(titlegap(0) axis(1)) yscale(titlegap(0) axis(2))
*
*
*PANEL B
bys  year: egen corr_year_natsubnat=corr(v2elffelr_pos_standard v2elfrfair_pos_standard)
*MOVING AVERAGE CORRELATION FIGURE
xtset country_id year 
gen corr_year_natsubnat_MA=(F1.corr_year_natsubnat+corr_year_natsubnat+L1.corr_year_natsubnat)/3
*FIGURE 1. PANEL B Correlation FIGURE
tsline corr_year_natsubnat_MA if year>1999 & year<2023, /// 
 ysize(1) xsize(1) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small)) /// 
 scheme(lean1) yscale(titlegap(0)) yscale(titlegap(0)) xlabel(2000(4)2022) /// 
graphregion(margin(2 2 2 2)) plotregion(margin(0 0 0 0)) xtitle("Year", size(small)) /// 
ytitle("Correlation Coefficient (3-year Moving Average)", size(small)) /// 
subtitle("Corr. Between Free & Fair Elections across Territorial Scales", size(small)) /// 
text(.838 2019 "All Countries", size(vsmall)) 
*
**************************************************************************************************************************************************
**************************************************************************************************************************************************
**************************************************************************************************************************************************
*FIGURE 3: Multilevel Regime Decoupling 1990-2022
*INDEITFY PERIOD OF INTEREST
gen period=. 
replace period=1 if year>1989 & year<2000
replace period=2 if year>1999 & year<2010 
replace period=3 if year>2009 
replace period=-99 if period==.
*CONFIRM YEARS
bys period: sum year
*ESTIMATE AVERAGE DEM SCORE PER PERIOD
gen e_polity2mod=e_polity2
replace e_polity2mod=. if e_polity2<-10
bys country_id period: egen mean_polity_period=mean(e_polity2mod)
*IDENTIFY DEMOCRATIC REGIMES PER PERIOD. 
gen dem_period_dummy=. 
replace dem_period_dummy=1 if mean_polity_period>5
replace dem_period_dummy=0 if dem_period_dummy==. 
*
keep country_id year e_regionpol v2elffelr_pos_standard v2xel_frefair_standard v2elsnlsff_pos_standard v2elfrfair_pos_standard period dem_period_dummy 
*
keep if year>1989
*
bysort country_id period (year): gen dem_nat_ave = (v2elfrfair_pos_standard + v2elfrfair_pos_standard[_n-1])/2 if year == year[_n-1] + 1
bysort country_id period (year): gen dem_subnat_ave = (v2elffelr_pos_standard + v2elffelr_pos_standard[_n-1])/2 if year == year[_n-1] + 1
*
bysort country_id period: gen first_nat_dem=dem_nat_ave if _n==2
bysort country_id period: gen second_nat_dem=dem_nat_ave if _n==_N
*
bysort country_id period: gen first_subnat_dem=dem_subnat_ave if _n==2
bysort country_id period: gen second_subnat_dem=dem_subnat_ave if _n==_N
*
bysort country_id period: egen mean_first_nat_dem=mean(first_nat_dem)
bysort country_id period: egen mean_second_nat_dem=mean(second_nat_dem)
*
bysort country_id period: egen mean_first_subnat_dem=mean(first_subnat_dem)
bysort country_id period: egen mean_second_subnat_dem=mean(second_subnat_dem)
*
*GENERATE  DIFFERENCES
gen nat_difference=mean_second_nat_dem-mean_first_nat_dem
gen subnat_difference=mean_second_subnat_dem-mean_first_subnat_dem
*
*GEN CLASSIFICATION OF QUADRANTS
gen class_difflevel=. 
replace class_difflevel=1 if nat_difference>=0  & subnat_difference>=0
replace class_difflevel=2 if nat_difference<0  & subnat_difference>=0
replace class_difflevel=3 if nat_difference<0  & subnat_difference<0
replace class_difflevel=4 if nat_difference>0  & subnat_difference<0
*
*TABULATE ALL AND DEMOCRACIES ONLY
tab period class_difflevel, row
tab period class_difflevel if dem_period_dummy==1, row
*TABULATE BY REGION
egen tag=tag(country_id period class_difflevel)
keep if tag==1
tab e_regionpol class_difflevel if period==1 & dem_period_dummy==1, row
tab e_regionpol class_difflevel if period==2 & dem_period_dummy==1, row
tab e_regionpol class_difflevel if period==3 & dem_period_dummy==1, row
*
*PANEL A 1990-2000
scatter subnat_difference nat_difference if period==1, yline(0, lpat(dash) lcol(gs7)) xline(0, lpat(dash) lcol(gs7)) jitter(2)  graphregion(margin(2 2 2 2)) plotregion(margin(0 0 0 0)) yscale(titlegap(0)) ysize(1) xsize(1)  ylabel(-.6(.2).8) xlabel(-.6(.2).8) subtitle("1990-2000", pos(12)) xtitle("Nat. Free & Fair {&Delta} ") ytitle("Subnat. Free & Fair {&Delta} ") msymbol(circle_hollow) mlw(vthin) mlcol(black)  msize(small) scheme(lean1) /// 
text(.7 .7 "I" .7 -.5 "II" -.5 .7 "IV" -.5 -.5 "III") /// 
text(.6 .7 "74%" .6 -.5 "17%" -.4 .7 "3%" -.4 -.5 "6%", size(small)) /// 
text(-.4 .2345 "H{subscript:o}: {&beta}Q{subscript:n}==0; F=34.6{superscript:***}", size(small)) /// 
text(-.5 .2693 "H{subscript:o}: {&beta}Q{subscript:n}=={&beta}Q{subscript:n}; F=17.58{superscript:***}", size(small)) 
*
*PANEL B 2000-2010
scatter subnat_difference nat_difference if period==2, yline(0, lpat(dash) lcol(gs7)) xline(0, lpat(dash) lcol(gs7)) jitter(2)   graphregion(margin(2 2 2 2)) plotregion(margin(0 0 0 0)) yscale(titlegap(0)) ysize(1) xsize(1)  ylabel(-.6(.2).8) xlabel(-.6(.2).8) subtitle("2000-2010", pos(12)) xtitle("Nat. Free & Fair {&Delta} ") ytitle("Subnat. Free & Fair {&Delta} ") msymbol(circle_hollow) mlw(vthin) mlcol(black) msize(small) scheme(lean1) /// 
text(.7 .7 "I" .7 -.5 "II" -.5 .7 "IV" -.5 -.5 "III") /// 
text(.6 .7 "63%" .6 -.5 "23%" -.4 .7 "6%" -.4 -.5 "8%", size(small)) /// 
text(-.4 .2345 "H{subscript:o}: {&beta}Q{subscript:n}==0; F=62.6{superscript:***}", size(small)) /// 
text(-.5 .2693 "H{subscript:o}: {&beta}Q{subscript:n}=={&beta}Q{subscript:n}; F=48.02{superscript:***}", size(small)) 
*
*
*PANEL C 2010-2022
scatter subnat_difference nat_difference if period==3, yline(0, lpat(dash) lcol(gs7)) xline(0, lpat(dash) lcol(gs7)) jitter(3)  graphregion(margin(2 2 2 2)) plotregion(margin(0 0 0 0)) yscale(titlegap(0)) ysize(1) xsize(1)  ylabel(-.6(.2).8) xlabel(-.6(.2).8) subtitle("2010-2022", pos(12)) xtitle("Nat. Free & Fair {&Delta} ") ytitle("Subnat. Free & Fair {&Delta} ") msymbol(circle_hollow) mlw(vthin) mlcol(black) msize(small) scheme(lean1) /// 
text(.7 .7 "I" .7 -.5 "II" -.5 .7 "IV" -.5 -.5 "III") /// 
text(.6 .7 "33%" .6 -.5 "30%" -.4 .7 "13%" -.4 -.5 "25%", size(small))  /// 
text(-.45 .249 "H{subscript:o}: {&beta}Q{subscript:n}==0; F=51.7{superscript:***}", size(small)) /// 
text(-.55 .279 "H{subscript:o}: {&beta}Q{subscript:n}=={&beta}Q{subscript:n}; F=46.7{superscript:***}", size(small)) 
*
**************************************************************************************************************************************************
**************************************************************************************************************************************************
*FIGURE 4: Further Quantitative Assessments of Multilevel Regime Decoupling
*PANEL A
*LOAD V-DEM DATA
use "V-Dem-CY-Full+Others-v13.dta", clear
*SET AS PANEL 
xtset country_id year
* STANDARDIZE VARIABLES BETWEEN 0-1
gen v2elffelr_pos=v2elffelr+3.459
gen v2elfrfair_pos=v2elfrfair+3.373
*
foreach var in v2elffelr_pos  v2elfrfair_pos {
	qui sum `var'
	gen `var'_standard= (`var' - `r(min)') / (`r(max)'-`r(min)')
}
*
sum  v2elffelr_pos_standard
sum  v2elfrfair_pos_standard
*SIMPLIFY DF
keep country_name country_id COWcode country_text_id year v2elffelr_pos_standard  v2elfrfair_pos_standard e_regionpol e_gdppc e_wb_pop
keep if year>1979
*GENERATE ABSOLUTE DIFFERENCE
gen natsubnatdiff=v2elfrfair_pos_standard-v2elffelr_pos_standard
gen natsubnatdiff_abs=abs(natsubnatdiff)
sum natsubnatdiff_abs
*
*EXPLORE ABSOLTE DIFFERENCE
*Global Mean 
bys year: egen natsubnatdiff_abs_globalyearmean=mean(natsubnatdiff_abs)
xtset country_id year
gen MA_nsdiff_abs_globalyearmean=(F1.natsubnatdiff_abs_globalyearmean+natsubnatdiff_abs_globalyearmean+L1.natsubnatdiff_abs_globalyearmean)/3
*Period Identifiers
gen period=. 
replace period=1 if year>1989 & year<2000
replace period=2 if year>1999 & year<2010
replace period=3 if year>2009 & year<2023
*
tsline MA_nsdiff_abs_globalyearmean if year>1989, /// 
scheme(lean1) xtitle("Year", size(medsmall)) xlabel(, labsize(medsmall)) ///
ytitle("|{&Delta}| Nat.-Subnat. Free & Fair (3-year MA)", size(medsmall)) ylabel(,labsize(medsmall)) ///
graphregion(margin(2 2 2 2)) plotregion(margin(0 0 0 0)) yscale(titlegap(0)) ///
yscale(titlegap(0)) ysize(1) xsize(1) ///
xline(2000, lpattern(shortdash) lcol(maroon) lwidth(thin)) /// 
xline(2010, lpattern(shortdash) lcol(maroon) lwidth(thin)) ///
text(0.11 1994.5 "Panel A", size(medsmall)) /// 
text(.108 1997.5 "Coverage: Global V-Dem Data", size(vsmall))
**************************************************************************************************************************************************
**************************************************************************************************************************************************
*FIGURE 4 PANEL B
*GET FIDALGO  DATA FROM: https://doi.org/10.7910/DVN/OPD3LW
*GET SANDOVAL DATA FROM: https://doi.org/10.7910/DVN/KO9C2M
*GET VANHANEN DATA FROM: https://services.fsd.tuni.fi/catalogue/FSD1289?tab=download&lang=en&study_language=en
*CLEAN, PREP, AND MERGE DATA WITH V-DEM (DATA WRANGLING CODE FILE AVAILABLE UPON REQUEST).
*LOAD MERGED FILE*
use "MergedAltMeasures.dta", clear
*TURN FIDALGO POSITIVE
gen SUBNAT_FIDALGO_pos = SUBNAT_FIDALGO  + 1.596858
*STANDARDIZE
foreach var in NATVdem_polyarchy NAT_VanhanenDem SUBNAT_ISED SUBNAT_FIDALGO_pos {
	qui sum `var'
	gen `var'_stnd= (`var' - `r(min)') / (`r(max)'-`r(min)')
}
*SET AS PANEL
xtset country_id year
*ISED vs Vanhanen COMPARISON
gen natsubnatdiff_VISED=  NAT_VanhanenDem_stnd - SUBNAT_ISED_stnd
gen natsubnatdiff_VISED_abs=abs(natsubnatdiff_VISED)
bys year: egen natsubnatdiff_VISED_absGlobal=mean(natsubnatdiff_VISED_abs)
tsline natsubnatdiff_VISED_absGlobal
*FIDALGO VS POLYARCHY(EDI) COMPARISON
gen natsubnatdiff_FID=  NATVdem_polyarchy_stnd - SUBNAT_FIDALGO_pos_stnd
gen natsubnatdiff_FID_abs=abs(natsubnatdiff_FID)
bys year: egen natsubnatdiff_FID_absglobal=mean(natsubnatdiff_FID_abs)
tsline natsubnatdiff_FID_absglobal
*MOVING AVERAGES
xtset country_id year
gen MAnatsubnatdiff_VISED_absGlobal=(F1.natsubnatdiff_VISED_absGlobal+natsubnatdiff_VISED_absGlobal+L1.natsubnatdiff_VISED_absGlobal)/3
xtset country_id year
gen MAnatsubnatdiff_FID_absglobal=(F1.natsubnatdiff_FID_absglobal+natsubnatdiff_FID_absglobal+L1.natsubnatdiff_FID_absglobal)/3
*
tsline MAnatsubnatdiff_VISED_absGlobal, yaxis(1) lpat(shortdash) lcol(emerald%20) || ///
lowess  MAnatsubnatdiff_VISED_absGlobal year, yaxis(1) lpat(solid)  lcol(dkgreen%80)  || ///
tsline MAnatsubnatdiff_FID_absglobal, yaxis(2) lpat(shortdash)  lcol(emidblue%50) || /// 
lowess  MAnatsubnatdiff_FID_absglobal year, yaxis(2) lpat(solid)  lcol(dknavy%80) ///
,scheme(lean1) /// 
ytitle("|{&Delta}| Subnat. ISED vs Nat. Vanhanen (3-year MA)", size(medsmall) axis(1)) ///
ytitle("|{&Delta}| Subnat. SEDS vs V-Dem Polyarchy (3-year MA)", size(medsmall) axis(2)) ///
xtitle("Year", size(medsmall)) xlab(,labsize(medsmall)) ///
legend(order(2 "ISED-Vanhanen" 4 "SEDS - V-Dem Polyarchy") size(vsmall) pos(5) ring(0)) ///
ylabel(, labsize(medsmall) axis(1)) ylabel(, labsize(medsmall)axis(2))  graphregion(margin(2 2 2 2)) /// 
plotregion(margin(0 0 0 0)) ysize(1) xsize(1) /// 
text(.198 1999 "Panel B: Alt. Measures", size(medsmall)) /// 
text(.195 1993 "Coverage:", size(vsmall)) /// 
text(.193 1996.4 "SEDS: Federal countries", size(vsmall)) ///
text(.191 1996 "ISED: Americas & India", size(vsmall))
**************************************************************************************************************************************************
**************************************************************************************************************************************************
*FIGURE 4 PANEL C
*Variable sources are described on the online appendix.
use "RegressionNatSubnatDifferences.dta", clear
*
xtset country_id year
*
*Econ Development (World Bank GDP pc USD PPP)
xtreg natsubnatdiff_abs gdppc_log   i.year, fe robust cluster(country_id) 
outreg2 using mydoc.doc, replace keep(gdppc_log) ctitle(1) addtext(Country FE, Yes, Year FE, Yes) label
*
*Population (World Bank) 
xtreg natsubnatdiff_abs e_wb_pop_log  i.year, fe robust cluster(country_id) 
outreg2 using mydoc.doc, append keep(e_wb_pop_log) ctitle(2) addtext(Country FE, Yes, Year FE, Yes) label
*
*Ethnic Fractionalization 
xtreg natsubnatdiff_abs ethnic_frac i.region_id i.year, robust cluster(country_id) 
outreg2 using mydoc.doc, append keep(ethnic_frac) ctitle(3) addtext(Country FE, Region FE, Year FE, Yes) label
*
*Terrain Rugged Nunn & Puga 2012
xtreg natsubnatdiff_abs terrain_rugged  i.region_id i.year , robust cl(country_id)
outreg2 using mydoc.doc, append keep(terrain_rugged) ctitle(4) addtext(Country FE, Region FE, Year FE, Yes) label
*
*FEDERALISM Forum of Federations and Blume & Voigt
xtreg natsubnatdiff_abs i.FEDERALISM_DUMMY  i.region_id i.year , robust cl(country_id)
outreg2 using mydoc.doc, append keep(i.FEDERALISM_DUMMY) ctitle(5) addtext(Country FE, Region FE, Year FE, Yes) label
*
*STATE CAPACITY
xtreg natsubnatdiff_abs inv_state_fsi i.year, fe robust cl(country_id)
outreg2 using mydoc.doc, append keep(inv_state_fsi) ctitle(6) addtext(Country FE, Yes, Year FE, Yes) label
*Measured with SFI
xtreg natsubnatdiff_abs inv_state_sfi  i.year, fe robust cl(country_id)
outreg2 using mydoc.doc, append keep(inv_state_sfi) ctitle(7) addtext(Country FE, Yes, Year FE, Yes) label
*
*RAI 
xtreg natsubnatdiff_abs rai_index  i.year, fe robust cl(country_id)
outreg2 using mydoc.doc, append keep(rai_index) ctitle(8) addtext(Country FE, Yes, Year FE, Yes) label
*
*EMB CAPACITY Garnett
xtreg natsubnatdiff_abs emb_overall_capacity  i.region_id i.year, robust cl(country_id)
outreg2 using mydoc.doc, append keep(emb_overall_capacity) ctitle(9) addtext(Country FE, Region FE, Year FE, Yes) label
*
*EMB Type IDEA 
xtreg natsubnatdiff_abs i.emb_typeBIN  i.region_id i.year, robust cl(country_id)
outreg2 using mydoc.doc, append keep(i.emb_typeBIN) ctitle(10) addtext(Country FE, Region FE, Year FE, Yes) label
*
*Governmental System 
xtreg natsubnatdiff_abs i.pres_parlBIN  i.region_id i.year, robust cl(country_id)
outreg2 using mydoc.doc, append keep(i.pres_parlBIN) ctitle(11) addtext(Country FE, Region FE, Year FE, Yes) label
*
*Electoral System 
xtreg natsubnatdiff_abs i.prop_rep_bin  i.region_id i.year, robust cl(country_id)
outreg2 using mydoc.doc, append keep(i.prop_rep_bin) ctitle(12) addtext(Country FE, Region FE, Year FE, Yes) label
*
*Saturated Model
xtreg natsubnatdiff_abs gdppc_log e_wb_pop_log ethnic_frac terrain_rugged i.FEDERALISM_DUMMY inv_state_fsi rai_index emb_overall_capacity i.emb_typeBIN i.pres_parlBIN i.prop_rep_bin i.region_id i.year, robust cl(country_id)
outreg2 using mydoc.doc, append keep(gdppc_log e_wb_pop_log ethnic_frac terrain_rugged i.FEDERALISM_DUMMY inv_state_fsi rai_index emb_overall_capacity i.emb_typeBIN i.pres_parlBIN i.prop_rep_bin) ctitle(13) addtext(Country FE, Region FE, Year FE, Yes) label
*
*Sat Model 2
xtreg natsubnatdiff_abs gdppc_log e_wb_pop_log ethnic_frac terrain_rugged i.FEDERALISM_DUMMY inv_state_sfi rai_index emb_overall_capacity i.emb_typeBIN i.pres_parlBIN i.prop_rep_bin i.region_id i.year, robust cl(country_id)
outreg2 using mydoc.doc, append keep(gdppc_log e_wb_pop_log ethnic_frac terrain_rugged i.FEDERALISM_DUMMY inv_state_sfi rai_index emb_overall_capacity i.emb_typeBIN i.pres_parlBIN i.prop_rep_bin) ctitle(14) addtext(Country FE, Region FE, Year FE, Yes) label
*
*Regression With RAI Subcomponents
xtreg natsubnatdiff_abs rai_n_selfrule i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, replace keep(rai_n_selfrule) ctitle(1) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_sharedrule  i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_sharedrule) ctitle(2) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_selfrule rai_n_sharedrule i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_selfrule rai_n_sharedrule) ctitle(3) addtext(Country FE, Yes, Year FE, Yes) label
*SUBCOMPONENTS
xtreg natsubnatdiff_abs rai_n_instdepth i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_instdepth) ctitle(4) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_policyautonomy i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_policyautonomy) ctitle(5) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_fiscalautonomy i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_fiscalautonomy) ctitle(6) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_borrowautonomy i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_borrowautonomy) ctitle(7) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_representation_11 i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_representation_11) ctitle(8) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_lawmaking_12 i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_lawmaking_12) ctitle(9) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_execcontrol i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_execcontrol) ctitle(10) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_fiscalcontrol i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_fiscalcontrol) ctitle(11) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_borrowcontrol i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_borrowcontrol) ctitle(12) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_constitutional i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_constitutional) ctitle(13) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_assembly i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_assembly) ctitle(14) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_executive i.year, fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_executive) ctitle(15) addtext(Country FE, Yes, Year FE, Yes) label
*
xtreg natsubnatdiff_abs rai_n_instdepth rai_n_policyautonomy rai_n_fiscalautonomy rai_n_borrowautonomy rai_n_representation_11 rai_n_lawmaking_12 rai_n_execcontrol  rai_n_fiscalcontrol rai_n_borrowcontrol rai_n_constitutional rai_n_assembly rai_n_executive i.year , fe robust cl(country_id)
outreg2 using mydoc2.doc, append keep(rai_n_instdepth rai_n_policyautonomy rai_n_fiscalautonomy rai_n_borrowautonomy rai_n_representation_11 rai_n_lawmaking_12 rai_n_execcontrol  rai_n_fiscalcontrol rai_n_borrowcontrol rai_n_constitutional rai_n_assembly rai_n_executive) ctitle(16) addtext(Country FE, Yes, Year FE, Yes) label
*
*REPEAT REGRESSIONS FOR FACTORS WITH SIGNIFICANCE AT SOME POINT. 
*STORE THOSE ESTIMATES AND PLOT THEM
*
xtreg natsubnatdiff_abs inv_state_fsi i.year, fe robust cl(country_id)
estimates store statecapBV
*
xtreg natsubnatdiff_abs rai_index  i.year, fe robust cl(country_id)
estimates store raiBV
*
xtreg natsubnatdiff_abs emb_overall_capacity  i.region_id i.year, robust cl(country_id)
estimates store embcapBV
*
xtreg natsubnatdiff_abs i.emb_typeBIN  i.region_id i.year, robust cl(country_id)
estimates store embtyBV
*
xtreg natsubnatdiff_abs rai_n_fiscalautonomy i.year, fe robust cl(country_id)
estimates store fiscauBV
*
xtreg natsubnatdiff_abs gdppc_log e_wb_pop_log ethnic_frac terrain_rugged i.FEDERALISM_DUMMY inv_state_fsi rai_index emb_overall_capacity i.emb_typeBIN i.pres_parlBIN i.prop_rep_bin i.region_id i.year, robust cl(country_id)
estimates store MVOne
*
xtreg natsubnatdiff_abs gdppc_log e_wb_pop_log ethnic_frac terrain_rugged i.FEDERALISM_DUMMY inv_state_sfi rai_index emb_overall_capacity i.emb_typeBIN i.pres_parlBIN i.prop_rep_bin i.region_id i.year, robust cl(country_id)
estimates store MVTwo
*
xtreg natsubnatdiff_abs rai_n_instdepth rai_n_policyautonomy rai_n_fiscalautonomy rai_n_borrowautonomy rai_n_representation_11 rai_n_lawmaking_12 rai_n_execcontrol  rai_n_fiscalcontrol rai_n_borrowcontrol rai_n_constitutional rai_n_assembly rai_n_executive i.year , fe robust cl(country_id)
estimates store MVRai
*
*COEF PLOT
coefplot (statecapBV raiBV embcapBV embtyBV fiscauBV, label(Bivariate) ci /// 
		keep(inv_state_fsi rai_index emb_overall_capacity *.emb_typeBIN rai_n_fiscalautonomy) msymbol(o) msize(small) mcolor(gs7)) ///
		(MVOne, label(Multivar. Model A) keep(inv_state_fsi emb_overall_capacity ) offset(0.25) msymbol(s) msize(small) mcolor(gs7)) /// 
		(MVTwo, label(Multivar. Model B) keep(rai_index *.emb_typeBIN) offset(0.25) msymbol(d) msize(small) mcolor(gs7)) /// 
		(MVRai, label(Multivar. Model C) keep(rai_n_fiscalautonomy) offset(0.25) msymbol(t) msize(small) mcolor(gs7)) /// 
		, order (rai_index rai_n_fiscalautonomy emb_overall_capacity *.emb_typeBIN inv_state_fsi) /// 
		drop(_cons) xline(0, lcol(red) lpat(dash) lwidth(vthin)) levels(88) ciopts(lcolor(gs13)) ///
		byopts(xrescale) mlabel format(%9.3f) mlabposition(12) mlabgap(*2) mlabsize(vsmall) ///
		scheme(lean1) leg(pos(8) ring(0) size(small))  /// 
		xtitle("{&beta}") /// 
		xlabel(,labsize(small)) yscale(off) ysize(1) xsize(1) ///
		text(.85 -0.025 "Regional Authority Index", size(small) color(navy)) ///
		text(1.8 -0.025 "Regional Fiscal Autonomy", size(small) color(navy)) /// 
		text(3 -0.03 "EMB Capacity", size(small) color(navy)) /// 
		text(3.9 -0.06 "EMB Type (Gov.)", size(small) color(navy)) ///
		text(4.8 -0.022 "Fragile State Index", size(small) color(navy)) /// 
		text(0.7 -0.075 "Panel C")
**************************************************************************************************************************************************
**************************************************************************************************************************************************
*FIGURES 5 THROUGH 8: CASES
use "V-Dem-CY-Full+Others-v13.dta", clear
*GEN POSITIVE VALUES
gen v2elffelr_pos=v2elffelr+3.459
gen v2elsnlsff_pos=v2elsnlsff+3.219
gen v2elfrfair_pos=v2elfrfair+3.373
*STD BETWEEN 0 & 1
foreach var in v2elffelr_pos v2xel_frefair v2elsnlsff_pos v2elfrfair_pos {
	qui sum `var'
	gen `var'_standard= (`var' - `r(min)') / (`r(max)'-`r(min)')
}
*
xtset country_id year
gen ma_v2elffelr_pos_standard=(F1.v2elffelr_pos_standard+v2elffelr_pos_standard+L1.v2elffelr_pos_standard)/3
*
*ITALY
tsline v2elfrfair_pos_standard if country_id==82 & year>2009, lcol(navy) yaxis(1) || /// 
,scheme(lean1) subtitle("National Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
*
tsline ma_v2elffelr_pos_standard  if country_id==82 & year>2009, lcol(purple) lpat(dash) yaxis(1) || /// 
,scheme(lean1) subtitle("Subational Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
*INDIA
tsline v2elfrfair_pos_standard if country_id==39 & year>2009, lcol(navy) yaxis(1) || /// 
,scheme(lean1) subtitle("National Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
*
tsline ma_v2elffelr_pos_standard  if country_id==39 & year>2009, lcol(purple) lpat(dash) yaxis(1) || /// 
,scheme(lean1) subtitle("Subational Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
*
*SOUTH AFRICA*
tsline v2elfrfair_pos_standard if country_id==8 & year>2009, lcol(navy) yaxis(1) || /// 
,scheme(lean1) subtitle("National Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
*
tsline ma_v2elffelr_pos_standard  if country_id==8 & year>2009, lcol(purple) lpat(dash) yaxis(1) || /// 
,scheme(lean1) subtitle("Subational Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
*
*UNITED STATES*
tsline v2elfrfair_pos_standard if country_id==20 & year>2009, lcol(navy) yaxis(1) || /// 
,scheme(lean1) subtitle("National Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
*
tsline ma_v2elffelr_pos_standard  if country_id==20 & year>2009, lcol(purple) lpat(dash) yaxis(1) || /// 
,scheme(lean1) subtitle("Subational Free & Fair Elections", ring(0) pos(10) size(medsmall)) xtitle("Year",size(medsmall)) /// 
ytitle("Score", axis(1) size(medsmall)) yscale(titlegap(0)) yscale(titlegap(0)) /// 
ysize(1) xsize(1) xlabel(2010(2)2022) ylabel(,labsize(small) axis(1)) xlabel(,labsize(small))
**************************************************************************************************************************************************
**************************************************************************************************************************************************
